import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace PerBusinessEmployeeApi {
  /** 人员基本信息信息 */
  export interface BusinessEmployee {
    id: number; // 业务ID
    busiId?: number; // 业务主表id
    employeeId?: number; // 人员id
    systemPersonId: number; // 系统人员ID，对应 system_person.id
    fullName?: string; // 姓名
    cardType: string; // 证件类型
    idcard: string; // 身份证号
    formerName: string; // 曾用名
    sex: number; // 性别
    birthDate: Dayjs | number; // 出生年月
    ethnicity: string; // 民族
    nativePlace: string; // 籍贯
    birthPlace: string; // 出生地
    mobile: string; // 联系电话
    householdAddress: string; // 户籍地址
    currentAddress: string; // 常住地址
    homeAddress: string; // 家庭地址
    identityType: string; // 身份类别
    employmentDate: Dayjs | number; // 参加工作时间
    status: number; // 状态
    postId: string; // 岗位
    politicalStatus: string; // 政治面貌
    partyJoinDate: Dayjs | number; // 入党时间
    highestEducation: string; // 最高学历
    graduationSchool: string; // 毕业院校
    graduationDate: Dayjs | number; // 毕业时间
    major: string; // 专业
    fileNumber: string; // 档案号
    photoUrl: string; // 照片
    unitId: number; // 单位id
    deptId: number; // 部门ID
    areaCode: number; // 行政区划编码
    remarks: string; // 备注
    changeType: string; // 变更类型（add：新增，update：修改，delete：删除）
    changeContent: string; // 变更内容(JSON格式，记录变更前后对比)
    auditStatus: number; // 审核状态（0草稿，1待审核，2审核中，3退回，4已通过）
    auditTime: Dayjs | number; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
    staffType: string; // 编制类型
    teachingSubject: string; // 任教学科
    teacherCertificate: string; // 教师资格证
    teachingStartDate: Dayjs | number; // 从教起始时间
  }
}

/** 查询人员基本信息分页 */
export function getBusinessEmployeePage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<PerBusinessEmployeeApi.BusinessEmployee>
  >('/per/businessEmployee/page', data, {
    desensitize,
    encrypt,
  });
}

/** 查询人员基本信息详情 */
export function getBusinessEmployee(id: number) {
  return requestClient.get<PerBusinessEmployeeApi.BusinessEmployee>(
    `/per/businessEmployee/get?id=${id}`,
  );
}

/** 新增人员基本信息 */
export function createBusinessEmployee(
  data: PerBusinessEmployeeApi.BusinessEmployee,
) {
  return requestClient.post('/per/businessEmployee/create', data);
}

/** 修改人员基本信息 */
export function updateBusinessEmployee(
  data: PerBusinessEmployeeApi.BusinessEmployee,
) {
  return requestClient.put('/per/businessEmployee/update', data);
}

/** 删除人员基本信息 */
export function deleteBusinessEmployee(id: number) {
  return requestClient.delete(`/per/businessEmployee/delete?id=${id}`);
}

/** 批量删除人员基本信息 */
export function deleteBusinessEmployeeList(ids: number[]) {
  return requestClient.delete(
    `/per/businessEmployee/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出人员基本信息 */
export function exportBusinessEmployee(params: any) {
  return requestClient.download('/per/businessEmployee/export-excel', {
    params,
  });
}

/** 获取当前登录人员基本信息（个人端） */
export function getCurrentEmployeeProfile(data: any, desensitize?: boolean) {
  return requestClient.post<PerBusinessEmployeeApi.BusinessEmployee>(
    '/per/businessEmployee/getCurrentEmployeeProfile',
    data,
    {
      desensitize,
    },
  );
}

/** 根据业务主表id去查询业务数据 */
export function getEmployeeBusiId(data: any) {
  return requestClient.post<PerBusinessEmployeeApi.BusinessEmployee>(
    `/per/businessEmployee/getEmployeeBusiId`,
    data,
  );
}
